﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Helper;
using System.ComponentModel;
namespace CoreData
{
    public class Stock_Method
    {
        [Description("ID")]
            public long ID{get;set;}
        [Description("Mã")]
            public string Code{get;set;}
        [Description("Tên")]
            public string Name{get;set;}
        [Description("Loại")]
            public string MethodType{get;set;}
        [Description("Mô tả")]
            public string Description { get; set; }
        [Description("Sử dụng")]
            public bool Active{get;set;}
         
        public Stock_Method()
        {       
                            Code ="";
                            Description = "";
                            Name ="";   
                           // Type ="";   
        }
        
       static Stock_Method DynamicCast<T>(object row_data, object row_header) where T : Stock_Method
       {
           // row_data : DataRow
           // row_header : DataColumnCollection
           Stock_Method ret = new Stock_Method();
           DataRow dt = (DataRow)row_data;

           foreach (DataColumn column in (DataColumnCollection)row_header)
           {
               switch (column.ColumnName)
               {
                      case  "ID":
                        ret.ID = ConvertObject.ToLong(dt[column]);
                       break;
                      case  "Code":
                        ret.Code = ConvertObject.ToString(dt[column]);
                       break;
                      case  "Name":
                        ret.Name = ConvertObject.ToString(dt[column]);
                       break;
                      case  "MethodType":
                       string methodtype = ConvertObject.ToString(dt[column]);
                       if (methodtype == "OUT")
                       {
                           ret.MethodType = "Xuất";
                        }
                       else
                       {
                           ret.MethodType = "Nhập";
                        }
                       break;
                      case  "Active":
                        ret.Active = ConvertObject.ToBool(dt[column]);
                       break;
                   case "Description":
                       ret.Description = ConvertObject.ToString(dt[column]);
                       break;
                
                   default:
                       break;
               }
           }

           return ret;
       }
        
    }
}
